function probes = computeProbes( config , classifier_bank_path, pairs)    

    dataset_n = length( config.datasets );
    
    classifier_n = length( classifier_bank_path );            
        
    probes = cell( dataset_n,  size( pairs ,1 ) );                
    
    try
        timer = toc;
    catch
        tic;        
        timer = toc;
    end
        

    for i = 1:dataset_n

        dataset_folder = [config.res_pool_root config.datasets{i}.name '/'];
        
        dataset_start_time = toc;
        
        for k = 1:size( pairs ,1)
            j1 = pairs( k , 1);
            j2 = pairs( k , 2);        

                classifier_name1 = classifier_bank_path(j1).name;
                classifier_name2 = classifier_bank_path(j2).name;

                folder_name1 = classifier_name1(1:end-9);
                folder_name2 = classifier_name2(1:end-9);

                save_folder1 = [dataset_folder folder_name1 '/'];
                save_folder2 = [dataset_folder folder_name2 '/'];                                

                probes{i,k} = computeProbe(config.datasets{i}, save_folder1, save_folder2 , config.res_type);            
                
                if( toc - timer > 20 )
                    save( './temp/probes', 'probes' );
                    disp(['time rest for this dataset ' num2str( (toc-dataset_start_time)/k*(size(probes,2)-k))]);
                    timer = toc;
                end            
        end        
    end
end

function probe = computeProbe( config, save_folder1, save_folder2 , res_type )
    n = length( config.src_list );
    probe = zeros( 1, n );
    
    if strcmp( res_type , config.src_type )
        name_format = @(A)(A);
    else
        name_format = @(str)( [ str( 1:end-length(res_type) ) res_type ] );
    end
    
    for i = 1:n
        probe(i) = getFrameProbe( ...
            [save_folder1 name_format(config.src_list{i})] ,...
            [save_folder2 name_format(config.src_list{i})]);
    end        
end

function probe = getFrameProbe(name_res1, name_res2)
    
    if( ...
        isempty( dir( name_res1 ) ) ...
        ||isempty( dir( name_res2 ) ) )
    
        probe = NaN;        
    else

        res1 = reviseType( imread( name_res1 ) );
        res2 = reviseType( imread( name_res2 ) );

        res1 = imresize( res1, [300 300] );
        res2 = imresize( res2, [300 300] );

        diff = (res1 - res2).^2;

        probe = mean( diff(:) );
    end
end

function nimg = reviseType( img )
    if( size(img,3)==3 )
        img = rgb2gray( img );
    end
    
    nimg = double( img ) / 255.0;
end